#include "jService.h"
#include "jservice_runner.h"
static int s_serviceCount = 0;
bool JService::tryQueueMsg( JServiceMsg* msg )
{	
	m_listMsgs.push_back(msg);
	return true;
}

void JService::markWorking()
{
	m_working = true;
}

JServiceMsg* JService::dequeueMsg()
{
	JServiceMsg* ret = NULL;
	if(!m_listMsgs.empty()) {
		ret = *m_listMsgs.begin();
	}
	return ret;
}

void JService::unmarkWorking()
{
	m_working = false;
}

void JService::onMsg( JService* service, int msgId, int sessionId, void* args )
{
}

JService::JService()
{
	m_working = false;
}

void JService::sendMsg( int sourceId, int msgId, int sessionId, void* args )
{
	m_runner->sendServiceMsg(sourceId, this->m_id, msgId, sessionId, args);
}

void JService::onStart( void* startArgs )
{
	m_startTime = GetTickCount();
	//
}

JService::~JService()
{

}

int JService::getId()
{
	return m_id;
}

